#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <utility>

class BigInt {
    public:

    BigInt(const std::string& str);
    BigInt(const char *str);

    bool assign(const std::string& str);
    bool assign(const char *str);

    static bool isLeagalBigIntStr(const std::string& str);

    enum FLAG {
        NEGATIVE = -1,
        ZERO = 0,
        POSITIVE = 1
    };
    template<typename T>
    BigInt(T a);
        BigInt(BigInt && a) {
            this->v = std::move(a.v);
            flag = a.flag;
        }
        BigInt& operator=(BigInt && a) {
            if ( &a != this) {
                this->v.clear();
                this->v = std::move(a.v);
                flag = a.flag;
            }
            return *this;
        }
        BigInt(const BigInt &b){
               this->v.clear();
               this->v = std::move(b.v);
               flag = b.flag;
        }

        std::string toString() const {
            std::string ret;
            if (flag == NEGATIVE)
                ret.push_back('-');
            
            for (auto rit = v.rbegin(); rit != v.rend(); ++rit) {
                ret.append(std::to_string(*rit));
            }

            return ret;
        }
        
        bool isSameFlag(const BigInt &b) const {
            return flag == b.flag;
        }
        int toInt() const {
            int ans = 0;
            for (int num: v) {
                ans = ans * BASE + num;
            }
            return ans;
        }
        bool isZero() const  {
            return v.size() == 1 && v[0] == 0;
        }

        int getFlag() const {
            return flag;
        }
        BigInt LeftShift(int shift_cnt = 1) {
            if ( isZero() || shift_cnt < 1)
                return *this;
            
            for (int j = 0; j < shift_cnt;j++)
                v.insert(v.begin(), 0);
            return *this;
        }
        BigInt RightShift(int shift_cnt = 1) {
            if (v.size() <= shift_cnt) {
                setZero();
            }
            else {
                v.erase(v.begin(), v.begin() + shift_cnt);
            }
    
            return BigInt(*this);
        }
    
        bool equal(const BigInt &b) const {
            auto vsz = v.size();
            if (vsz != b.v.size())
                return false;
            if (flag != b.flag)
                return false;
            
            for (auto i = 0;i < vsz; i++) {
                if (v[i] != b.v[i])
                    return false;
            }
            return true;
        }


        std::size_t getLen() const {
            return v.size();
        }
    
        void print() const ;
    
        BigInt& operator=(const BigInt &q) {
            if (this != &q) {
                v = q.v;
                flag = q.flag;
            }
            return *this;
        }
    
        void setZero() {
            v.clear();
            v.push_back(0);
            flag = ZERO;
        }
        void setOne() {
            v.clear();
            v.push_back(1);
            flag = POSITIVE;
        }
        void test() {
            BigInt t(100);
            *this = t;
        }
        int AbsCompareTo(const BigInt &b) const {
            if ( v.size() != b.v.size())
                return v.size() > b.v.size()? 1 : -1;
            
            std::vector<int>::const_reverse_iterator bit = b.v.rbegin(); 

            for (auto it = v.rbegin(); it != v.rend(); ++it, ++bit) {
                if (*it != *bit) {
                    return *it > *bit ? 1 : -1;
                }
            }
    
            return 0;
        }

        int CompareTo(const BigInt &b) const {
            if (this->flag != b.flag)
                return this->flag > b.flag ? 1 : -1;
            return AbsCompareTo(b);
        }

        
        const BigInt& Add(const BigInt &add);
        const BigInt& Minus(const BigInt &n);
    
        BigInt Div(const BigInt &div);

        const BigInt & Multiply(int p);
        const BigInt& Multiply(const BigInt &mul);    

    private:
        
    BigInt AbsAdd(const BigInt &) const;
    BigInt AbsMinus(const BigInt &) const;
        BigInt(int len,int v);
        int flag{ZERO};
        static constexpr int BASE = 10;
        std::vector<int> v;
};